package com.pengcheng.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pengcheng.common.valid.AddGroup;
import com.pengcheng.common.valid.UpdateGroup;
import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@TableName("sys_user")
public class SysUserEntity implements Serializable {

    @TableId
    private Long userId;

    @NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String username;

    @NotBlank(message="密码不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String password;

    @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
    private String email;

    @NotBlank(message="手机号码不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "1[3|4|5|7|8][0-9]\\d{8}",message = "请注意手机号格式", groups = {AddGroup.class,UpdateGroup.class})
    private String mobile;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
    private Date createTime;

    @TableLogic
    private Integer deleted;

    @TableField(exist=false)
    private List<Long> roleList;

}
